1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.AboutDialog; 26 27 private import gdk.PaintableIF; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.Widget; 34 private import gtk.Window; 35 private import gtk.c.functions; 36 public import gtk.c.types; 37 private import std.algorithm; 38 39 40 /** 41 * The `GtkAboutDialog` offers a simple way to display information about 42 * a program. 43 * 44 * The shown information includes the programs' logo, name, copyright, 45 * website and license. It is also possible to give credits to the authors, 46 * documenters, translators and artists who have worked on the program. 47 * 48 * An about dialog is typically opened when the user selects the `About` 49 * option from the `Help` menu. All parts of the dialog are optional. 50 * 51 *  52 * 53 * About dialogs often contain links and email addresses. `GtkAboutDialog` 54 * displays these as clickable links. By default, it calls [func@Gtk.show_uri] 55 * when a user clicks one. The behaviour can be overridden with the 56 * [signal@Gtk.AboutDialog::activate-link] signal. 57 * 58 * To specify a person with an email address, use a string like 59 * `Edgar Allan Poe <edgar@poe.com>`. To specify a website with a title, 60 * use a string like `GTK team https://www.gtk.org`. 61 * 62 * To make constructing a `GtkAboutDialog` as convenient as possible, you can 63 * use the function [func@Gtk.show_about_dialog] which constructs and shows 64 * a dialog and keeps it around so that it can be shown again. 65 * 66 * Note that GTK sets a default title of `_("About %s")` on the dialog 67 * window (where `%s` is replaced by the name of the application, but in 68 * order to ensure proper translation of the title, applications should 69 * set the title property explicitly when constructing a `GtkAboutDialog`, 70 * as shown in the following example: 71 * 72 * ```c 73 * GFile *logo_file = g_file_new_for_path ("./logo.png"); 74 * GdkTexture *example_logo = gdk_texture_new_from_file (logo_file, NULL); 75 * g_object_unref (logo_file); 76 * 77 * gtk_show_about_dialog (NULL, 78 * "program-name", "ExampleCode", 79 * "logo", example_logo, 80 * "title", _("About ExampleCode"), 81 * NULL); 82 * ``` 83 * 84 * ## CSS nodes 85 * 86 * `GtkAboutDialog` has a single CSS node with the name `window` and style 87 * class `.aboutdialog`. 88 */ 89 public class AboutDialog : Window 90 { 91 /** the main Gtk struct */ 92 protected GtkAboutDialog* gtkAboutDialog; 93 94 /** Get the main Gtk struct */ 95 public GtkAboutDialog* getAboutDialogStruct(bool transferOwnership = false) 96 { 97 if (transferOwnership) 98 ownedRef = false; 99 return gtkAboutDialog; 100 } 101 102 /** the main Gtk struct as a void* */ 103 protected override void* getStruct() 104 { 105 return cast(void*)gtkAboutDialog; 106 } 107 108 /** 109 * Sets our main struct and passes it to the parent class. 110 */ 111 public this (GtkAboutDialog* gtkAboutDialog, bool ownedRef = false) 112 { 113 this.gtkAboutDialog = gtkAboutDialog; 114 super(cast(GtkWindow*)gtkAboutDialog, ownedRef); 115 } 116 117 118 /** */ 119 public static GType getType() 120 { 121 return gtk_about_dialog_get_type(); 122 } 123 124 /** 125 * Creates a new `GtkAboutDialog`. 126 * 127 * Returns: a newly created `GtkAboutDialog` 128 * 129 * Throws: ConstructionException GTK+ fails to create the object. 130 */ 131 public this() 132 { 133 auto __p = gtk_about_dialog_new(); 134 135 if(__p is null) 136 { 137 throw new ConstructionException("null returned by new"); 138 } 139 140 this(cast(GtkAboutDialog*) __p); 141 } 142 143 /** 144 * Creates a new section in the "Credits" page. 145 * 146 * Params: 147 * sectionName = The name of the section 148 * people = The people who belong to that section 149 */ 150 public void addCreditSection(string sectionName, string[] people) 151 { 152 gtk_about_dialog_add_credit_section(gtkAboutDialog, Str.toStringz(sectionName), Str.toStringzArray(people)); 153 } 154 155 /** 156 * Returns the names of the artists which are displayed 157 * in the credits page. 158 * 159 * Returns: A 160 * `NULL`-terminated string array containing the artists 161 */ 162 public string[] getArtists() 163 { 164 return Str.toStringArray(gtk_about_dialog_get_artists(gtkAboutDialog)); 165 } 166 167 /** 168 * Returns the names of the authors which are displayed 169 * in the credits page. 170 * 171 * Returns: A 172 * `NULL`-terminated string array containing the authors 173 */ 174 public string[] getAuthors() 175 { 176 return Str.toStringArray(gtk_about_dialog_get_authors(gtkAboutDialog)); 177 } 178 179 /** 180 * Returns the comments string. 181 * 182 * Returns: The comments 183 */ 184 public string getComments() 185 { 186 return Str.toString(gtk_about_dialog_get_comments(gtkAboutDialog)); 187 } 188 189 /** 190 * Returns the copyright string. 191 * 192 * Returns: The copyright string 193 */ 194 public string getCopyright() 195 { 196 return Str.toString(gtk_about_dialog_get_copyright(gtkAboutDialog)); 197 } 198 199 /** 200 * Returns the name of the documenters which are displayed 201 * in the credits page. 202 * 203 * Returns: A 204 * `NULL`-terminated string array containing the documenters 205 */ 206 public string[] getDocumenters() 207 { 208 return Str.toStringArray(gtk_about_dialog_get_documenters(gtkAboutDialog)); 209 } 210 211 /** 212 * Returns the license information. 213 * 214 * Returns: The license information 215 */ 216 public string getLicense() 217 { 218 return Str.toString(gtk_about_dialog_get_license(gtkAboutDialog)); 219 } 220 221 /** 222 * Retrieves the license type. 223 * 224 * Returns: a [enum@Gtk.License] value 225 */ 226 public GtkLicense getLicenseType() 227 { 228 return gtk_about_dialog_get_license_type(gtkAboutDialog); 229 } 230 231 /** 232 * Returns the paintable displayed as logo in the about dialog. 233 * 234 * Returns: the paintable displayed as 235 * logo or `NULL` if the logo is unset or has been set via 236 * [method@Gtk.AboutDialog.set_logo_icon_name] 237 */ 238 public PaintableIF getLogo() 239 { 240 auto __p = gtk_about_dialog_get_logo(gtkAboutDialog); 241 242 if(__p is null) 243 { 244 return null; 245 } 246 247 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p); 248 } 249 250 /** 251 * Returns the icon name displayed as logo in the about dialog. 252 * 253 * Returns: the icon name displayed as logo, 254 * or `NULL` if the logo has been set via [method@Gtk.AboutDialog.set_logo] 255 */ 256 public string getLogoIconName() 257 { 258 return Str.toString(gtk_about_dialog_get_logo_icon_name(gtkAboutDialog)); 259 } 260 261 /** 262 * Returns the program name displayed in the about dialog. 263 * 264 * Returns: The program name 265 */ 266 public string getProgramName() 267 { 268 return Str.toString(gtk_about_dialog_get_program_name(gtkAboutDialog)); 269 } 270 271 /** 272 * Returns the system information that is shown in the about dialog. 273 * 274 * Returns: the system information 275 */ 276 public string getSystemInformation() 277 { 278 return Str.toString(gtk_about_dialog_get_system_information(gtkAboutDialog)); 279 } 280 281 /** 282 * Returns the translator credits string which is displayed 283 * in the credits page. 284 * 285 * Returns: The translator credits string 286 */ 287 public string getTranslatorCredits() 288 { 289 return Str.toString(gtk_about_dialog_get_translator_credits(gtkAboutDialog)); 290 } 291 292 /** 293 * Returns the version string. 294 * 295 * Returns: The version string 296 */ 297 public string getVersion() 298 { 299 return Str.toString(gtk_about_dialog_get_version(gtkAboutDialog)); 300 } 301 302 /** 303 * Returns the website URL. 304 * 305 * Returns: The website URL 306 */ 307 public string getWebsite() 308 { 309 return Str.toString(gtk_about_dialog_get_website(gtkAboutDialog)); 310 } 311 312 /** 313 * Returns the label used for the website link. 314 * 315 * Returns: The label used for the website link 316 */ 317 public string getWebsiteLabel() 318 { 319 return Str.toString(gtk_about_dialog_get_website_label(gtkAboutDialog)); 320 } 321 322 /** 323 * Returns whether the license text in the about dialog is 324 * automatically wrapped. 325 * 326 * Returns: `TRUE` if the license text is wrapped 327 */ 328 public bool getWrapLicense() 329 { 330 return gtk_about_dialog_get_wrap_license(gtkAboutDialog) != 0; 331 } 332 333 /** 334 * Sets the names of the artists to be displayed 335 * in the "Credits" page. 336 * 337 * Params: 338 * artists = the authors of the artwork 339 * of the application 340 */ 341 public void setArtists(string[] artists) 342 { 343 gtk_about_dialog_set_artists(gtkAboutDialog, Str.toStringzArray(artists)); 344 } 345 346 /** 347 * Sets the names of the authors which are displayed 348 * in the "Credits" page of the about dialog. 349 * 350 * Params: 351 * authors = the authors of the application 352 */ 353 public void setAuthors(string[] authors) 354 { 355 gtk_about_dialog_set_authors(gtkAboutDialog, Str.toStringzArray(authors)); 356 } 357 358 /** 359 * Sets the comments string to display in the about dialog. 360 * 361 * This should be a short string of one or two lines. 362 * 363 * Params: 364 * comments = a comments string 365 */ 366 public void setComments(string comments) 367 { 368 gtk_about_dialog_set_comments(gtkAboutDialog, Str.toStringz(comments)); 369 } 370 371 /** 372 * Sets the copyright string to display in the about dialog. 373 * 374 * This should be a short string of one or two lines. 375 * 376 * Params: 377 * copyright = the copyright string 378 */ 379 public void setCopyright(string copyright) 380 { 381 gtk_about_dialog_set_copyright(gtkAboutDialog, Str.toStringz(copyright)); 382 } 383 384 /** 385 * Sets the names of the documenters which are displayed 386 * in the "Credits" page. 387 * 388 * Params: 389 * documenters = the authors of the documentation 390 * of the application 391 */ 392 public void setDocumenters(string[] documenters) 393 { 394 gtk_about_dialog_set_documenters(gtkAboutDialog, Str.toStringzArray(documenters)); 395 } 396 397 /** 398 * Sets the license information to be displayed in the 399 * about dialog. 400 * 401 * If `license` is `NULL`, the license page is hidden. 402 * 403 * Params: 404 * license = the license information 405 */ 406 public void setLicense(string license) 407 { 408 gtk_about_dialog_set_license(gtkAboutDialog, Str.toStringz(license)); 409 } 410 411 /** 412 * Sets the license of the application showing the about dialog from a 413 * list of known licenses. 414 * 415 * This function overrides the license set using 416 * [method@Gtk.AboutDialog.set_license]. 417 * 418 * Params: 419 * licenseType = the type of license 420 */ 421 public void setLicenseType(GtkLicense licenseType) 422 { 423 gtk_about_dialog_set_license_type(gtkAboutDialog, licenseType); 424 } 425 426 /** 427 * Sets the logo in the about dialog. 428 * 429 * Params: 430 * logo = a `GdkPaintable` 431 */ 432 public void setLogo(PaintableIF logo) 433 { 434 gtk_about_dialog_set_logo(gtkAboutDialog, (logo is null) ? null : logo.getPaintableStruct()); 435 } 436 437 /** 438 * Sets the icon name to be displayed as logo in the about dialog. 439 * 440 * Params: 441 * iconName = an icon name 442 */ 443 public void setLogoIconName(string iconName) 444 { 445 gtk_about_dialog_set_logo_icon_name(gtkAboutDialog, Str.toStringz(iconName)); 446 } 447 448 /** 449 * Sets the name to display in the about dialog. 450 * 451 * If `name` is not set, the string returned 452 * by `g_get_application_name()` is used. 453 * 454 * Params: 455 * name = the program name 456 */ 457 public void setProgramName(string name) 458 { 459 gtk_about_dialog_set_program_name(gtkAboutDialog, Str.toStringz(name)); 460 } 461 462 /** 463 * Sets the system information to be displayed in the about 464 * dialog. 465 * 466 * If `system_information` is `NULL`, the system information 467 * page is hidden. 468 * 469 * See [property@Gtk.AboutDialog:system-information]. 470 * 471 * Params: 472 * systemInformation = system information 473 */ 474 public void setSystemInformation(string systemInformation) 475 { 476 gtk_about_dialog_set_system_information(gtkAboutDialog, Str.toStringz(systemInformation)); 477 } 478 479 /** 480 * Sets the translator credits string which is displayed in 481 * the credits page. 482 * 483 * The intended use for this string is to display the translator 484 * of the language which is currently used in the user interface. 485 * Using `gettext()`, a simple way to achieve that is to mark the 486 * string for translation: 487 * 488 * ```c 489 * GtkWidget *about = gtk_about_dialog_new (); 490 * gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (about), 491 * _("translator-credits")); 492 * ``` 493 * 494 * It is a good idea to use the customary `msgid` “translator-credits” 495 * for this purpose, since translators will already know the purpose of 496 * that `msgid`, and since `GtkAboutDialog` will detect if “translator-credits” 497 * is untranslated and omit translator credits. 498 * 499 * Params: 500 * translatorCredits = the translator credits 501 */ 502 public void setTranslatorCredits(string translatorCredits) 503 { 504 gtk_about_dialog_set_translator_credits(gtkAboutDialog, Str.toStringz(translatorCredits)); 505 } 506 507 /** 508 * Sets the version string to display in the about dialog. 509 * 510 * Params: 511 * version_ = the version string 512 */ 513 public void setVersion(string version_) 514 { 515 gtk_about_dialog_set_version(gtkAboutDialog, Str.toStringz(version_)); 516 } 517 518 /** 519 * Sets the URL to use for the website link. 520 * 521 * Params: 522 * website = a URL string starting with `http://` 523 */ 524 public void setWebsite(string website) 525 { 526 gtk_about_dialog_set_website(gtkAboutDialog, Str.toStringz(website)); 527 } 528 529 /** 530 * Sets the label to be used for the website link. 531 * 532 * Params: 533 * websiteLabel = the label used for the website link 534 */ 535 public void setWebsiteLabel(string websiteLabel) 536 { 537 gtk_about_dialog_set_website_label(gtkAboutDialog, Str.toStringz(websiteLabel)); 538 } 539 540 /** 541 * Sets whether the license text in the about dialog should be 542 * automatically wrapped. 543 * 544 * Params: 545 * wrapLicense = whether to wrap the license 546 */ 547 public void setWrapLicense(bool wrapLicense) 548 { 549 gtk_about_dialog_set_wrap_license(gtkAboutDialog, wrapLicense); 550 } 551 552 /** 553 * Emitted every time a URL is activated. 554 * 555 * Applications may connect to it to override the default behaviour, 556 * which is to call [func@Gtk.show_uri]. 557 * 558 * Params: 559 * uri = the URI that is activated 560 * 561 * Returns: `TRUE` if the link has been activated 562 */ 563 gulong addOnActivateLink(bool delegate(string, AboutDialog) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 564 { 565 return Signals.connect(this, "activate-link", dlg, connectFlags ^ ConnectFlags.SWAPPED); 566 } 567 }